
import React, { Component } from 'react'

// import { Route, Switch, Redirect } from 'react-router-dom'


import Tabbar from 'components/Tabbar/Tabbar'

import home from 'images/tabbar/sy_tab@3x.png'
import homeSel from 'images/tabbar/sy_tab_s@3x.png'
import find from 'images/tabbar/fx_tab@3x.png'
import findSel from 'images/tabbar/fx_tab_s@3x.png'
import hall from 'images/tabbar/dt_tab@3x.png'
import hallSel from 'images/tabbar/dt_tab_s@3x.png'
import my from 'images/tabbar/wd_tab@3x.png'
import mySel from 'images/tabbar/wd_tab_s@3x.png'

import Home from '../home/Home'
import Find from '../find/Find'
import My from '../my/My'
import Hall from '../hall/Hall'
import { log } from 'util'

// 底部tabbar组件显示参数
const tabArrs = [
  {
    title : "首页",
    normalImg : home,
    selectedImg : homeSel,
    routePath : "/index/home",
    component : Home,
    tag : 0,
  },
  {
    title : "发现",
    normalImg : find,
    selectedImg : findSel,
    routePath : "/index/find",
    component : Find,
    tag : 1,
  },
  {
    title : "大厅",
    normalImg : hall,
    selectedImg : hallSel,
    routePath : "/index/hall",
    component : Hall,
    tag : 2,
  },
  {
    title : "我的",
    normalImg : my,
    selectedImg : mySel,
    routePath : "/index/my",
    component : My,
    tag : 3,
  },
  
]
let defIndex = 0

class Index extends Component {
  render() {
    // console.log(this.props)
    
    for(var i in tabArrs){
      // console.log(i,
      //   this.props.location.pathname,
      //   this.props.location.pathname.indexOf(tabArrs[i].routePath))
      if(this.props.location.pathname.indexOf(tabArrs[i].routePath) === 0){
        defIndex = tabArrs[i].tag
        // console.log(defIndex)
      }
    }
    // console.log(defIndex)
    
    return (
      <>
        <Tabbar
          // background = "#fff"
          normalColor = "#646464"
          selectedColor = "#56D9D1"
          tabArr = {tabArrs}
          selectedIndex = {defIndex}
        ></Tabbar>
      </>
    );
  }
}

export default Index;

